Skip to content

feat: update spending balance modal - #1373

Merged
ovitrif merged 147 commits into
masterfrom
feat/update-spending-balance-modal
Nov 24, 2026
Merged

ovitrif merged 147 commits into
masterfrom
feat/update-spending-balance-modal

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1374

Stacked on #1355
Twin: synonymdev/bitkit-android#1967

Description

  • Replaces the Move to Spark screens with the v64 modal: "Update Spending Balance" with the live routing fee as "Update fee: ", Later and Update; on success "Spending Balance Updated" with OK. The one-time sheet and the Move To Spark buttons on Spending and Lightning Connections all open it.
  • Once the move settles, every channel it emptied is closed cooperatively and gets the usual transfer row; a failed close leaves the channel for a manual close. Channels that could send less than the move minimum are left alone, and nothing closes while another Lightning payment is in flight.
  • A Lightning payment that only the channels and Spark together can cover runs with one swipe: the confirm screen adds an "Update fee" row and opens its details so the fee shows before the swipe, which waits for the quote, the swipe moves the channel balance to Spark, then pays from Spark.
    • At swipe time, and again right before the move, the update is quoted again; if its fee rose, or none was shown, the payment returns to confirm with the new fee and nothing moves. An automatic payment that hits this falls back to a manual confirm.
    • An LNURL-pay that needs the update shows its fee before the first swipe.
    • Any failed update releases a payment request instead of leaving it pending; one refused for a risen fee is restored for the next swipe.
    • Before moving, the quote and Spark's balance must cover the payment; otherwise nothing moves.
    • A payment request refused by its allowance check moves nothing.
    • If the payment fails after the move, the funds stay in Spark and the usual payment error shows.
    • QuickPay never sends such a payment: it checks again right before paying and opens Confirm when the update is needed.
    • Contact payments can use the update; Pubky swaps are quoted only with what one rail can pay.
  • Removes the Spark Route row from the send confirm screen; the key stays for the Pubky Swaps row.
  • Removes the CJIT receive card, its button and the liquidity flow; CJIT history stays. Without Lightning receive, the Spending and Auto receive tabs hide.
  • Translates the new strings into every shipped locale and drops the removed keys from each.
  • Differs from the twin where iOS code differs:
    • The modal resets when its sheet is dismissed, as other iOS sheets do.
    • Channel closes reuse TransferViewModel.closeChannels.
    • The LNURL-pay confirm shows the Update fee row whenever the payment needs the update.
    • The Spending tab bar shortcut and Receive's Transfer Unavailable step go with the CJIT flow.
    • After the move, the payment waits up to 60 s for Spark's balance, rechecking every 2 s.

Out of Scope

  • If the app is killed after a move settles and before its channels close, they stay open for a manual close.
  • States without frames (a move in flight, nothing to move, too large, failed) keep today's behaviour in the modal.
  • DisplayText, BodyMText: the headline and body line heights are the shared components' (about 2 pt under the frame's 44 and 22).

Design

Figma page "Bitkit - Progress v64" in the Bitkit Wallet file:

Preview

Figma frame on the left, the app on the right, on 42a656e8f.

Update Spending Balance Spending Balance Updated

Screens without a v64 frame

Send confirm with the Update fee row Receive without the CJIT card

Recordings at 2x: J1 on 42a656e8f, J2 on f2b60fc6c, the others on 1ca4159a7.

J1: move to Spark J2: payment with an update J3: transfer unavailable
pr4-j12x.mp4
pr4-j22x.mp4
pr4-j32x.mp4
J4: USDT receive tabs J5: receive tabs wraparound
pr4-j42x.mp4
pr4-j52x.mp4

Figma notes

Every note above the v64 frames for these flows, with what this PR does about it.

Modal Update Spending balance (Spark)

  • "Bitkit is switching Lightning providers. Update your spending balance … Update fee": this PR, with the live routing fee

Modal Update Spending (Spark) done

  • "Funds moved to spark": this PR shows it once the move succeeds
  • "Also auto close channel after sending the funds to Spark balance": this PR closes every channel the move emptied

Changelog v64

QA Notes

Setup

  • Local Spark regtest stack from synonymdev/bitkit-docker (docs/spark-regtest.md), so the wallet holds an LDK channel to the stack's SSP Lightning node on the same chain as Spark.
  • Debug build (regtest) pointed at that stack: its local Spark config (SPARK_LOCAL_CONFIG_B64 from the docs) as the Spark SDK config with fee ladders off, Electrum on the stack, and the stack's chain API as Spark's chain service. This branch has no build setting for a local Spark, so this is a local patch to Env.swift and SparkManager.swift, not part of this PR.
  • J1: new wallet with 500 000 sats in savings and a 400 000-sat channel to the SSP node.
  • J2: a fresh compose project of the stack (new volumes), and a new wallet with savings, 30 000 on Spark, a 32 000-sat channel to the SSP node, QuickPay off, and a 50 000-sat invoice from another node on the stack.
  • J3: Spark failing to start (replace the wallet's regtest/wallet0/spark directory with a file), restored after.

Journeys

  • J1: updated move-to-spark.xml — Update modal with its fee, Later, Update, Updated modal, emptied channel closed — passed on 42a656e8f
  • J2: added update-spending-balance-payment.xml — a payment only channels and Spark together cover: "Update fee" row, no Route row, one swipe — passed on f2b60fc6c
  • J3: updated transfer-unavailable-sheet.xml — with Spark down, the funding options and Receive without Lightning tabs — passed on 1ca4159a7
  • J4: updated usdt-receive-swipe-tabs.xml — tabs without the CJIT card — passed on 1ca4159a7
  • J5: updated receive-tabs-wraparound.xml — passed on 1ca4159a7, step 10 included
  • J6: updated paykit-spark-route.xml (Route row removed) — not run: needs a paykit stack with a Pubky profile

Automated Checks

  • added MoveToSparkUpdateTests.swift — update-fee guard, coverage before moving, closing only the channels a move emptied, the swipe waiting for the newest quote
  • updated MoveToSparkMathTests.swift, MoveToSparkQuoteTests.swift, MoveToSparkLateOutcomeTests.swift — when a payment needs the update, swap routes and Spark legs never do
  • updated LnurlPayConfirmTests.swift — an automatic payment needing the update waits for a swipe; a refused fee restores only the current send
  • added QuickPayPaymentCoordinatorTests.swift case — a payment that needs the update falls back to Confirm
  • updated ReceiveTabsTests.swift — without Lightning receive the Spending and Auto tabs hide
  • removed ReceiveLiquidityDecisionTests.swift, TabBarReceiveTests.swift with the CJIT flow

Evidence

On an iPhone 17 Pro simulator (regtest) with the local Spark stack:

  • J1: the modal read "Update fee: ₿ 2"; Later kept it away after a relaunch; Update moved 394 602 sats to Spark and showed "Spending Balance Updated"; the channel closed cooperatively with its 4 060-sat remainder sent to savings; Lightning Connections listed only Spark via Breez, and the Move To Spark button was gone.
  • J2: confirm showed 50 000 with its details open, "Instant (± ₿ 202)", "Update fee ₿ 2" and no Route row; after the over-half-balance dialog, one swipe moved 30 458 to Spark and sent 50 000 from Spark, which needed more than its 30 000 balance; the emptied channel closed and savings received its 372-sat remainder.
  • J3: Spark failing to start left Manual Setup as the only enabled funding option, and Receive showed only Savings.
  • J4, J5: Receive has no CJIT card; the tabs wrap from USDT straight to Savings, and with USDT off run Savings, Spending, Savings, Auto.
  • Between 1ca4159a7 and 42a656e8f only the modal's artwork placement and fix: spark follow-ups #1355's base changes landed; the send, retry and Move to Spark test classes pass on 42a656e8f.

Gaps

  • J6, as above.
  • If the app is killed after a move settles and before its channels close, they stay open for a manual close.

Models used

  • Planning/scoping: Claude Opus 5.5 (reasoning: medium)
  • Implementation: Claude Opus 5.5 (reasoning: medium), Claude Sonnet 5.5 (reasoning: high)
  • Review: Claude Opus 5.5 (reasoning: medium)

Shows a move as a Move to Spark transfer row, re-checks the Move to Spark sheet after a cold-start sheet closes, keeps move payment hashes across relaunches, and injects the quote services so makeQuote is tested.
Stops quoting after a waiting early claim, sets aside exit data Spark rejects so backups go on, keeps a retry in doubt held against an earlier attempt's late failure, and fails the Release key check on a blank keychain item.
…ock skew

Keep each different rejected exit copy and keep the staged data when the
remote copy is gone; count a Spark failure as an earlier attempt only past
a 10 s clock margin; cache the move hashes Activity reads per row.

Verified: swiftformat --lint on changed files; unit tests pending on m1a
…ackup

Set aside the staged exit data itself when the remote backup no longer
holds it, instead of a fresh download that may be another device's.

Verified: swiftformat --lint on changed files; unit tests pending on m1a
Every rejected exit copy goes under SPARK_EXIT_REJECTED_ plus the first 16
hex digits of its SHA-256, so two devices setting different copies aside at
once can't overwrite each other.

Verified: swiftformat --lint on changed files; unit tests pending on m1a
Check whether a Spark failure belongs to an earlier attempt and end the hold
under one lock, so a retry recorded in between keeps its hold.

Verified: swiftformat --lint on the changed file; unit tests pending on m1a
Before a retried Spark send goes out, record Spark's ids of the invoice's
earlier attempts from the listing the send already reads. A late failure
ends the hold only when its payment id is not one of them. Without ids, a
failure created before the send or within the clock margin after it keeps
the hold, so an earlier attempt's failure can't free a duplicate payment.

Verified: ChannelFreeRailTests, MoveToSparkQuoteTests and SparkExitBackupTests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
A failure of an earlier attempt that arrives while a retry is in doubt
leaves the send's activity pending. When the hold then ends at the
invoice's expiry, write Spark's latest send of the invoice, or mark the
stored pending send failed when Spark lists none. Spark syncs now also
end holds whose invoice expired, so this no longer waits for a new send.

Verified: ChannelFreeRail, MoveToSpark activity, late outcome and quote, SparkExitBackup, SparkLightningSend, SparkPaymentSafety, SparkRelaunchActivity and SparkTransferActivity tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
A hold that ends at the invoice's expiry keeps its hash in a persisted
list until its activity is saved, so a failed Spark listing or write is
retried on the next Spark sync. Failing a stored pending send now reads,
checks and writes the row in one core-queue operation, so a change saved
in between isn't overwritten.

Verified: ChannelFreeRail, MoveToSpark activity, late outcome and quote, SparkExitBackup, SparkLightningSend, SparkPaymentSafety, SparkRelaunchActivity and SparkTransferActivity tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
A waiting early claim left the first quote's fee as the deposit's cap, so
Spark would not claim a later offer the user's approved fee still covers.
The claim now caps at the approved fee. After a waiting claim the poll
still sends no new quote; an offer above the approved fee ends as
Unavailable and is claimed at maturity.

Verified: SparkTransferFlow, SparkClaimOffer, SparkClaimFee, SparkFundingRecovery and ChannelFreeRail tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
When Spark rejects staged exit data and the remote backup now holds
another device's exit data, set the staged copy aside and restore the
remote one instead of uploading over it. After setting an unreadable
backup aside, read the remote again and keep the restore pending if it
changed meanwhile. A Spark send in doubt saved before this version, with
no start time or attempt ids, stays held against any failure until its
invoice expires.

Verified: ChannelFreeRail, SparkExitBackup, SparkExit, SparkRelaunchActivity, SparkPaymentSafety, SparkLightningSend and MoveToSparkQuote tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
Keep Spark's ids of a retry's earlier attempts after Spark takes the
retry, until it settles, so an earlier attempt's late failure neither
ends its hold nor fails its pending Activity row. Note the restore of
another device's exit backup before the staged copy is dropped, so a stop
in between still restores it, and count a staged exit file that can't be
read as pending rather than absent.

Verified: ChannelFreeRail, SparkExitBackup, SparkExit, SparkRelaunchActivity, SparkPaymentSafety, SparkLightningSend, MoveToSparkQuote and SparkTransferFlow tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
Spending and Lightning Connections offered Move to Spark only while the
channels had something to move, so a move in flight that used up their
balance hid its own screen. They now also offer it while a move is kept
for its result.

Verified: MoveToSparkLateOutcome, MoveToSparkQuote, MoveToSparkActivity and MoveToSparkMath tests pass on an iPhone 17 Pro simulator; swiftformat lint clean.
Once Spark took a retry, its listing can still show only the earlier
attempts' failures. Those failures now read pending while the invoice is
unexpired and no other attempt is listed, so the node never pays an
invoice the retry may still pay.

Verified: ChannelFreeRailTests, SparkTransferFlowTests, SparkExitBackupTests and MoveToSparkLateOutcomeTests pass on an iPhone 17 Pro simulator
The restore only stages the exit data; Spark imports it once connected
and may still reject it, so the log no longer calls it a success.

Verified: log wording only; SparkExitBackupTests pass on an iPhone 17 Pro simulator
Takes master's v64 Spark copy for strings both sides changed and keeps
this PR's translations of the keys master left alone, dropping keys the
merged English file no longer has. The move to Spark journey keeps
master's connections check and this PR's Activity row step.

Verified: node scripts/validate-translations.js passes; the unit suite (unit-tests.yml selection) passes on an iPhone 17 Pro simulator
Once Spark took a retry, the launch's activity sync released its hold
when Spark's list still showed only the earlier failed attempt. That
dropped the stored expiry the duplicate check reads, so the node could
pay the unexpired invoice while the retry may still settle.

The startup release now skips failures of the attempts listed before
the send Spark took, and releases the hold once Spark lists the retry
itself failed.

Verified: ChannelFreeRailTests, SparkPaymentSafetyTests, MoveToSparkQuoteTests and SparkExitBackupTests on an iOS simulator
@ovitrif ovitrif self-assigned this Nov 19, 2026
@ovitrif
ovitrif requested review from a team, ben-kaufman and coreyphillips and removed request for a team November 19, 2026 12:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T12:57:21.503711Z 42a656e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge based on the code reviewed.

Summary

Replaces the Move to Spark screens with an Update Spending Balance modal and lets Lightning payments combine channel and Spark funds after showing the update fee.

  • The Update Spending Balance modal moves channel funds to Spark and closes emptied channels.
  • One swipe can move channel funds to Spark and pay a Lightning invoice.
  • Receive no longer offers CJIT, and hides Lightning tabs when it cannot receive Lightning.

No actionable issues found. Tests were not run in this Linux environment.

ovitrif explicitly leaves app termination between move settlement and channel closure out of scope; those channels remain available for manual closure.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Review Lightning payment] --> B{Needs combined funds?}
    B -- No --> G[Send payment]
    B -- Yes --> C[Show update fee]
    C --> D[Swipe and refresh quote]
    D --> E{New or higher update fee?}
    E -- Yes --> C
    E -- No --> F[Check allowance and coverage]
    F --> H[Move channel funds to Spark]
    H --> I[Close emptied channels]
    H --> J[Wait for Spark balance]
    J --> G
Loading

Reviews (1) · Last reviewed commit: "fix: keep the modal artwork 32 above its..." · Reviewed by Greptile

App Status's Spark row opened the Spark connection detail only while
its status read ready, so offline, with Spark's state already read,
the detail could only be reached from Lightning Connections. The row
now opens it once Spark has read its state, as on Android.

Verified: AppStatusHelperTests and AppStatusExitTests on an iOS simulator
Replaces the Move to Spark screens with the Update Spending Balance
modal: the live routing fee as "Update fee", Later and Update, then
Spending Balance Updated with OK. The one-time timed sheet and the
Move To Spark buttons on Spending and Lightning Connections open it.
States without frames (in flight, partly moved, too large, failed) keep
their behaviour inside the modal; their dismiss buttons share the
UpdateSpendingBalanceDismiss id. The modal resets the move manager when
it closes.

Verified: swiftformat --lint on the changed Swift files
Once a move settles, on its first outcome or a late success, every
channel it emptied is closed cooperatively with the usual transfer row;
a failed close leaves the channel for a manual close. Channels that
could send less than the move minimum before it are left alone. This
replaces the single-channel Close button after a move.

Verified: swiftformat --lint on the changed Swift files
A Lightning payment that only the channels and Spark together can cover
runs with one swipe: confirm adds an "Update fee" row and opens its
details, the swipe waits for the quote, moves the channel balance to
Spark, then pays from Spark.

The update fee guard charges nothing the user did not see: the update
is quoted again at the swipe and right before the move, and a fee that
rose, or none shown, returns to confirm with the new fee and moves
nothing. Before moving, the quote and Spark's balance must cover the
payment and Spark's fee for it. A request refused by its allowance
check moves nothing, and any failed update releases the request. A
payment failing after the move leaves the funds in Spark with the usual
payment error. An LNURL-pay that needs the update shows its fee before
the first swipe. QuickPay never sends such a payment, and Paykit routes
are quoted only with what one rail can pay.

Verified: swiftformat --lint on the changed Swift files
Send confirm no longer shows the Route row for a Paykit payment over Spark. The Pubky Swaps route row keeps it, so wallet__send_swap_route stays, as on Android.

Verified: swiftformat --lint on the changed Swift files
@ovitrif
ovitrif requested a review from pwltr November 24, 2026 01:47

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 0d78546 against 1ef7403. The combined-balance send can start a paid Spark migration before it finishes checking whether the recipient payment can proceed.

Low: Check the effective Paykit deadline again at migration submission in SendConfirmationView.swift:2019 and LnurlPayConfirm.swift:385. A time-limited request can pass authorization and expire during migration preparation. The wallet can then pay the update fee and close an emptied channel while the recipient send is refused.

Low candidate: A still-valid invoice with a paid or pending attempt can reach migration before the existing duplicate check at SendConfirmationView.swift:2019 and LightningService.swift:1088. If Spark can price that repeat and the changed balances now need both rails, another swipe can move funds and trigger a close before send returns the earlier outcome.

Low candidate: MoveToSparkManager.swift:664 can accept a Spark quote that fits the projected balance but exceeds the cap applied at SparkManager.swift:652. A supported provider returning an above-cap quote both times would allow the paid move before the recipient send is refused.

Low: In the debug-regtest Pubky swap flow, SendAmountView.swift:114 offers the combined balance while SendAmountView.swift:449 enforces the one-rail cap. The maximum-fill shortcut can enable Continue with an amount that Continue immediately rejects. Apply the swap cap to the displayed and selectable amount.

Low candidate: ReceiveQr.swift:115 and ReceiveQr.swift:480 can use an expired cached Lightning invoice while Spark is unavailable and the channels have no inbound capacity. If Spending is selected before refresh suppresses the QR, it can display an unpayable invoice.

Low: MoveToSparkUpdateTests.swift:61 and MoveToSparkUpdateTests.swift:74 repeat the 50,000-sat and 31,999-sat assertions at lines 40–44 using the same fixtures. The contact routing and exact-capacity assertions provide distinct coverage.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

The update before a combined-balance send now moves nothing for an
expired Paykit request, a repeat of a paid or pending invoice, or a
Spark fee above the send's limit. A swap offers only what one rail
sends, and Spending receive waits for a fresh invoice when none can
be created.

Verified: MoveToSpark, Lnurl pay, send confirmation, channel-free rail, Spark transfer, WalletViewModel send and QuickPay unit tests on the simulator
@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pwltr all six are addressed in 465950f:

Check the effective Paykit deadline again at migration submission

Both confirm screens now pass the request's submission deadline to the update, which checks it right before the move is paid. An expired request moves nothing, and its own error reaches the screen.

A still-valid invoice with a paid or pending attempt can reach migration before the existing duplicate check

The update now runs the same earlier-attempt check send uses, on both rails, before quoting. A pending repeat is refused and a settled one skips the move, so the send returns the earlier outcome without moving funds.

can accept a Spark quote that fits the projected balance but exceeds the cap

The coverage check now refuses a Spark fee above the limit the send applies (1% + 50 sats), so no paid move goes ahead for a send that would then be refused.

The maximum-fill shortcut can enable Continue with an amount that Continue immediately rejects.

With a Pubky swap route set, the amount screen offers only what one rail sends, which is what Continue checks.

can use an expired cached Lightning invoice while Spark is unavailable and the channels have no inbound capacity

Spending now shows the refresh state instead of a cached QR while no invoice can be created.

repeat the 50,000-sat and 31,999-sat assertions

Removed both repeats, keeping the contact routing and exact-capacity checks.

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 465950f against 1ef7403.

Both confirmation screens re-read mutable payment state after awaiting the fresh Spending update quote. Bind the swipe to the active confirmation, route, funding source and amount, then verify that context before continuing.

Medium: For a unified invoice that needs a Spending update and can also be paid from Savings, tapping FROM while the quote loads can switch the old swipe to Savings. If Savings preparation finishes before the quote returns, the swipe can pick up the newly calculated mining fee and submit the on-chain payment without a second swipe. Bitkit/Views/Wallets/Send/SendConfirmationView.swift:1152, Bitkit/Views/Wallets/Send/SendConfirmationView.swift:2079.

Medium: For a variable-amount LNURL payment that needs the update, going Back and continuing with a different in-range amount while the quote loads can cause the old swipe to request and pay an invoice for the edited amount. The callback validates the amount it was asked for, so it cannot catch the change. Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:261, Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:322, Bitkit/Views/Wallets/Send/LnurlPayAmount.swift:126.

Low: A split-balance Paykit request that expires during the payment-list read or move queue wait can still incur the update fee before the recipient payment is refused. Pass the effective deadline to the existing LDK submission hook for the migration as well. Bitkit/Managers/MoveToSparkManager.swift:673, Bitkit/ViewModels/WalletViewModel.swift:1251.

Low: If a first LNURL subscription payment needs an update only after liquidity changes during its callback, the late-fee refusal opens the failure screen. Return it to manual confirmation with the new fee, as the BOLT11 path does. Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:227, Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:450.

Low: testAnUpdateThatFallsShortMovesNothing repeats the 49,875/49,876 sat boundary through checkCoverage. It would still pass if the move dispatched before the guard. Extend the existing test to observe dispatch or keep the distinct estimator-failure case under a name that describes the coverage check. BitkitTests/MoveToSparkUpdateTests.swift:110.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

A swipe that needs the spending update stops, moving and sending
nothing, when its source, route, invoice or amount changed while the
update was quoted. The Paykit deadline is checked again when the update
payment is submitted, and a first LNURL subscription payment stopped by
a late update fee returns to manual confirmation.

Verified: MoveToSpark, Lnurl pay, send confirmation, channel-free rail, Spark transfer, WalletViewModel send and QuickPay unit tests on the simulator
@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pwltr all five are addressed in aa83108:

Bind the swipe to the active confirmation, route, funding source and amount, then verify that context before continuing.

Each swipe that needs the update now records what it pays when it starts. After the update quote returns, it checks that record again, and stops with nothing moved or sent if anything changed.

tapping FROM while the quote loads can switch the old swipe to Savings

On Confirm, the swipe records the source, invoice or address, amount, and whether a service or swap route is set. Switching to Savings mid-quote stops the old swipe instead of submitting on-chain.

going Back and continuing with a different in-range amount while the quote loads can cause the old swipe to request and pay an invoice for the edited amount

LNURL Confirm records the LNURL and amount, and checks them after the quote and again right before requesting the invoice. An edited amount stops the old swipe.

Pass the effective deadline to the existing LDK submission hook for the migration as well.

The update payment now passes the deadline check to LDK's beforeSubmission hook, so it also holds after the payment-list read and any queue wait.

Return it to manual confirmation with the new fee, as the BOLT11 path does.

An automatic first subscription payment stopped by a late update fee now goes back to manual confirmation with the new fee, as the BOLT11 path does.

testAnUpdateThatFallsShortMovesNothing repeats the 49,875/49,876 sat boundary

Renamed it to testCoverageFailsWhenSparkCannotPriceThePayment and kept only the case where Spark cannot price the payment; the boundary lives in its own test.

@ovitrif
ovitrif requested a review from pwltr November 24, 2026 13:22
@ovitrif
ovitrif force-pushed the fix/spark-follow-ups-2 branch from 1ef7403 to 41ed0d3 Compare November 24, 2026 14:19
…t/update-spending-balance-modal

# Conflicts:
#	Bitkit/Managers/MoveToSparkManager.swift
#	Bitkit/Resources/Localization/ar.lproj/Localizable.strings
#	Bitkit/Resources/Localization/ca.lproj/Localizable.strings
#	Bitkit/Resources/Localization/cs.lproj/Localizable.strings
#	Bitkit/Resources/Localization/de.lproj/Localizable.strings
#	Bitkit/Resources/Localization/el.lproj/Localizable.strings
#	Bitkit/Resources/Localization/es-419.lproj/Localizable.strings
#	Bitkit/Resources/Localization/es.lproj/Localizable.strings
#	Bitkit/Resources/Localization/fr.lproj/Localizable.strings
#	Bitkit/Resources/Localization/it.lproj/Localizable.strings
#	Bitkit/Resources/Localization/nl.lproj/Localizable.strings
#	Bitkit/Resources/Localization/pl.lproj/Localizable.strings
#	Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings
#	Bitkit/Resources/Localization/pt.lproj/Localizable.strings
#	Bitkit/Resources/Localization/ru.lproj/Localizable.strings
#	Bitkit/Services/LightningService.swift
#	BitkitTests/MoveToSparkQuoteTests.swift
#	journeys/transfer/move-to-spark.xml

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 62c1e9e against befad53.

Low: The merge dropped lightning__spark_exit__note_notifications_button from 13 locale bundles. When a Spark Exit is active and notification permission is denied, the button at Bitkit/Views/Settings/Advanced/SparkExitViews.swift:968 falls back to English and shows “Turn on notifications.” Restore the entries from befad53 in Bitkit/Resources/Localization/*/Localizable.strings for ar, ca, cs, de, el, es-419, es, fr, it, pl, pt-BR, pt, and ru.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

…the screen

The spark exit notifications button string is back in 13 locales,
lost with the duplicate keys. A swipe whose payment changed while the
update was quoted no longer opens the failure screen or sets its quote
on the new payment, and Receive leaves Auto or Spending once they hide.

Verified: MoveToSpark, Lnurl pay, send confirmation, channel-free rail, Spark transfer, WalletViewModel send and receive tabs unit tests on the simulator; validate-translations
Going Back, closing the sheet or editing the payment while the spending balance update is quoted no longer shows its failure or continues the payment, and a changed payment after warnings or PIN is not sent.

Verified: swiftformat --lint; targeted BitkitTests on simulator
The Auto and Spending fallback also runs when the screen opens with Lightning receive already hidden. Tests cover the fallback and the update swipe bindings.

Verified: swiftformat --lint; targeted BitkitTests on simulator
The update swipe compares the invoice's own amount, so filling the send amount in from the invoice after PIN no longer stops an unchanged payment.

Verified: swiftformat --lint; targeted BitkitTests on simulator
Base automatically changed from fix/spark-follow-ups-2 to master November 24, 2026 16:25
@ovitrif
ovitrif dismissed coreyphillips’s stale review November 24, 2026 16:25

The base branch was changed.

github-actions Bot added a commit that referenced this pull request Nov 24, 2026
{"kind":"bitkit-retarget-execution-v1","repository":"synonymdev/bitkit-ios","pr":1373,"generation":"45436892534-1","sourceSha":"737b2f946459ed6bb8ab3ca718b4bbd9e1c9e8e8","sourceRef":"master","owner":"github-actions[bot]"}
@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Retargeting this PR onto master: its base, #1355, merged in 737b2f9, and its head is already in this branch, so the diff stays the same.

@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pwltr Restored lightning__spark_exit__note_notifications_button in all 13 locales from befad53 in e0a6457.

The same push also:

  • stops an update swipe once its confirm screen is left (Back, closing the sheet) or its payment changes, so a late quote neither shows its failure nor pays (a38fa3c)
  • keeps a fixed-amount invoice's swipe valid after PIN (da2636a)
  • moves Receive to Savings when it opens with Lightning receive already hidden (8ccac95)

@ovitrif
ovitrif requested a review from pwltr November 24, 2026 16:36

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed da2636a against 737b2f9.

Medium candidate: The final Spending update quote can outlive the confirmation that authorized it. When a payment needs both the channel and Spark balances, dismissing BOLT11 Confirm or tapping Back from variable-amount LNURL Confirm while the final quote is pending can still let Bitkit/Managers/MoveToSparkManager.swift:639 proceed to the channel move. If it settles and Spark has sufficient balance, Bitkit/Views/Wallets/Send/SendConfirmationView.swift:2033 can continue with the captured BOLT11 and Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift:406 can continue with the invoice for the old amount even after the payer returns to Amount. The source shows the path to submission. Whether the update fee or recipient payment settles after leaving Confirm remains unverified. Carry the confirmation identity through the final quote and check it immediately before submitting the move.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@pwltr Thanks. That final quote runs after the swipe has passed every check, inside the payment the swipe sent: the same invoice, the same amount, and a fee no higher than the one shown, or it stops at updateFeeUnseen. Leaving Confirm once a payment is underway doesn't cancel it, the same as a channel-only payment in flight, so the move and the payment go through as approved. The checks in this PR cover the window before that, while Confirm's own quote is still running.

@ovitrif

ovitrif commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Merging: approved at da2636a and every check is green. The e2e passed once its bitkit-e2e-tests branch was fast-forwarded to main; it had no commits of its own and its stale suite could not start a simulator session.

@ovitrif
ovitrif merged commit d9cf874 into master Nov 24, 2026
28 of 32 checks passed
@ovitrif
ovitrif deleted the feat/update-spending-balance-modal branch November 24, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: update spending balance modal

5 participants